CIT105P Rubrics | |
Assignment 6-7-8: Database 1, 2, 3 | |
Tables | 10 |
Search Query | 10 |
Report | 10 |
Total | 30 |
(Any other suggestions?) |
To make data entry easier for the database (instead of using the spreadsheet format) we can create Forms for our tables.
Open the CornerStore database which you created in assignment #1.
Click on the "Inventory" table listing in the left panel to highlight the name. Then click the "Create" Tab and on the ribbon for that tab click the "Form" button. This automatically generates a plain-Jane but servicable data entry form. (see below)
Hit Control-S to save or simply close the new form by clicking on the "X" in the upper right to get a save or don't save dialog. Answer "save" and you will get this "Save As" window. Enter the name for your form, in this case we are using "Inventory Entry" then click the "OK" button.
You now have a data entry form to make it easier to enter all the information for one record at a time.
What you should take out of this exercise:
Here we've clicked on the double chevron button to put all the fields previously listed on the left side, on the right side for Selected Fields.
Take the rest of the defaults to finish and display the report.
What you can be expected to take away from this.
If this were a real-world simulation we could break down a typical store invoice this way.
Notice how all the individual items listed on the invoice are tied to the invoice itself by including the invoice number in a correspoding "invoiceNumber" field in each line item (InvoceDetails table). The tie is a relationship. There are several table which are related here:
The Invoice Table record is the main record. It contains the employee ID of the sales person and the customer ID of the customer. In turn, each line item contains the record ID (invoice number) of the invoice.
In turn each line item recorded has the record number of the record in the inventory table which contains the original record about each item sold. But by itself the inventory table does not contain a field for the custormer who buys the item. That would not make sense. Instead that is kept in the invoice record which links to line items on the sales slip.
Because this is not a database course and because this is merely one assignment out of a number of assignments in a very introductory course we are going to "cheat" by directly relating some inventory items to some customer records. I REPEAT. This is ONLY to setup a relationship extra point assignment without having you make up a set of additional tables and filling them in. We do have a database course where we go through all the right steps but this is not it. Still, the whole point of a relational database is that we can relate one table to another (or to several) in order to ask more complicated questions than those we can answer with a simple card-file type database.
SO, HAVING WARNED YOU we are now going to slightly modify the inventory table in order to set up a relationship, for extra points, if you wish. This is ONLY to get a little bit of practice in setting relationships.
We will start our exercise by adding a field to our "Inventory" field. We will use the field to relate inventory items to customers.
At this point we need to enter some numbers which will allow us to link up (relate) items in the inventory table with customers. Our customers have Customer Numbers from 1 through 5 (remember, this is just a school illustration).
So, in the Inventory table's CustomerID column, type in numbers all the way down from 1 through 5. The number and order and number of each number is not important. This is just an example. Merely make sure you use all 5 numbers, at least once each. Don't use any other numbers otherwise the items won't show because they won't match the customer numbers. Later, as an experiment, you might want to enter some non-existent customer number and run the query we are going to make, just to see for yourself. It is always better to do your own playing with the program if you want to understand it.
With our matching data items entered it is time to click on the "DATABASE TOOLS" tab and then the "Relationships" button.
Now you have a list of tables in the "Show Table" dialog. Highlight "Customers" table and click the "Add" button. Do the same for the "Inventory" table. This will put a pair of table field list windows on screen. Click the "Close" button.
FINALLY, we are ready to describe the relationship to our database.
This is the relationship. There is nothing more to do for this. Now it is time to use the relationship in a query (storable, reusable question)
Time to make our new query using the related tables.
On the "Tables/Queries" pull down list box choose "Customers" table
On the "Tables/Queries" pull down list box choose "Customers" table
This is pretty much what your relationship query should look like. Depending on which records you gave with customer number to, it will vary somewhat from this, but will still work the same way.